﻿<?php



 $data=' {
       "button":[
       {
           "name":"7th-feeling",
           "sub_button":[
           {  
               "type":"view",
               "name":"品牌介绍",
               "url":"http://a3.rabbitpre.com/m/727mzjFZ9"
            },
            {
               "type":"view",
               "name":"联营手册",
               "url":"http://a2.rabbitpre.com/m/Efizr6mzj"
            },
            {
               "type":"view",
               "name":"门店展示",
               "url":"http://a3.rabbitpre.com/m/iieEzaO"
            },
            {
               "type":"view",
               "name":"新品鉴赏",
               "url":"http://a2.rabbitpre.com/m/vaaaiNQIf"
            }] 
       },
       {
                  "name":"微商城",
                  "sub_button":[
                  {  
                      "type":"view",
                      "name":"热卖男装",
                      "url":"http://dlshop.dliansoft.com/index.php/Mobile/Shop/index/type/indexman.html?dltoken=wxcd3cc358923b015c"
                   },
                   {
                      "type":"view",
                      "name":"热卖女装",
                      "url":"http://dlshop.dliansoft.com/index.php/Mobile/Shop/index/type/indexwoman.html?dltoken=wxcd3cc358923b015c"
                   },
                   {
                      "type":"view",
                      "name":"爆款秒杀",
                      "url":"http://dlshop.dliansoft.com/index.php/Mobile/Activity/flash_list/?dltoken=wxcd3cc358923b015c"
                   }] 
           },

    
        {
           "name":"VIP中心",
           "sub_button":[
           {
              "type":"view",
              "name":"玩转七夕",
              "url":"http://dlshop.dliansoft.com/index.php/Mobile/Draw/index/id/6.html?dltoken=wxcd3cc358923b015c"
           },
            {
               "type":"view",
               "name":"会员中心",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/User/index?dltoken=wxcd3cc358923b015c"
            },
            {
               "type":"view",
               "name":"会员卡",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/User/mycode?dltoken=wxcd3cc358923b015c"
            },
           {  
               "type":"view",
               "name":"会员注册",
               "url":"http://dlshop.dliansoft.com/index.php/Mobile/User/userinfo?dltoken=wxcd3cc358923b015c"
            }]
  }]
}';


 //定义创建菜单函数

function createMenu($data){

 $access_token='AkSdBlFeX_ZUlSR6SXg99Z-nWIAW87OZvkEa1eZ6fucMPA1FOpqAulyKF86rDEdXGu0GXVA4wTjUnPXFbdLEzrXxP7U2ZvkibZjqtTWtJBkBdicm3jckhmrtbtG-SxB3ULUaAFAMDM';

 $ch = curl_init();

 curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token);

 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');

 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

 curl_setopt($ch, CURLOPT_AUTOREFERER, 1);

 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

 $tmpInfo = curl_exec($ch);

 if (curl_errno($ch)) {

  return curl_error($ch);

 }

 curl_close($ch);

 return $tmpInfo;

}


 //获取token

    function getToken(){

        $APPID='wxcd3cc358923b015c';//微信公众号AppID

        $APPSECRET='55fd2b7a8eeec2caf4d29f9b6a97a01e';//微信公众号AppSecret

        $urlstr='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$APPID.'&secret='.$APPSECRET;

        $res = file_get_contents($urlstr);

        $resarr=json_decode($res,true);

        return  $resarr['access_token'];

        define('ACCESS_TOKEN',$resarr['access_token']);



      }

//创建菜单



echo createMenu($data);